class Solution
{
public:
    int secondHighest(string s)
    {
        unordered_set<char> chs(s.begin(), s.end());
        bool foundFirst = false;
        for (char c = '9'; c >= '0'; --c)
        {
            if (chs.count(c))
            {
                if (foundFirst)
                {
                    return c - '0';
                }
                else
                {
                    foundFirst = true;
                }
            }
        }
        return -1;
    }
};